package Demo1;

public class T20 {
    public static void main(String[] args) {
        Object locker = new Object();
        Thread thread1 = new Thread(()->{
            synchronized (locker){
                System.out.println("线程wait之前");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("线程wait之后");
            }
        });

        Thread thread2 = new Thread(()->{
            try {
                Thread.sleep(2000);
                System.out.println("notify之前");
                synchronized (locker){
                    locker.notify();
                    System.out.println("noity之后");
                }
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        thread1.start();
        thread2.start();
    }
}
